<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id = "myDiv"></div>
<script>
    var ajax = function (url, params, callback, method) {
        params = params || '';
        method = method || 'GET';
        var xhr = new window.XMLHttpRequest();
        console.log("url",url);
        xhr.onreadystatechange = function () {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    console.log("连接成功");
                    if(callback){
                        callback(xhr.responseText); //执行回调
                    }
                    console.log("连接成功")
                }
            }
        };
        xhr.open(method, url, true); //true为异步，false为同步
        xhr.send(params);
    };
    ajax("http://192.168.100.46:8080/show",'',function (result) {
        document.getElementById("myDiv").innerHTML = result;
    });
</script>
</body>
<!--</html>-->
